load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

cc_binary(
    name = "libmonitor.so",
    linkshared = True,
    linkstatic = False,
    deps = [":monitor_lib"],
)

cc_library(
    name = "monitor_lib",
    srcs = [
        "monitor.cc",
        "hardware/device_monitor.cc",
        "common/system_cmd.cc",
    ],
    hdrs = [
        "monitor.h",
        "hardware/device_monitor.h",
        "common/system_cmd.h",
    ],
    linkopts = [
        "-pthread -lz -lrt -luuid"
    ],
    deps = [
        "@com_github_google_glog//:glog",
        "@fastrtps//:fastrtps",
        "@com_github_gflags_gflags//:gflags",
        "@airosrt//:airosrt",
        "@yaml_cpp//:yaml_cpp",
        "//base/device_connect/proto:cloud_data_cc_pb",
        "//middleware/protocol/common:global_conf",
        ":rscu_status_cc_pb",
    ],
    copts = [
        "-DUSE_CYBERRT",
	      "-DMODULE_NAME=\\\"monitor\\\""
    ],
)

cc_proto_library( 
    name = "rscu_status_cc_pb", 
    deps = [":rscu_status_pb"], 
)

proto_library( 
    name = "rscu_status_pb", 
    srcs = ["proto/rscu_status.proto"], 
)

cc_test(
     name="monitor_ut",
     srcs = [
        "ut/monitor_test.cc",
        "monitor.h",
     ],
    linkopts = [
        "-pthread -lz"
    ],
    deps=[
      "@com_google_googletest//:gtest_main",
      ":monitor_lib",
    ],
    copts = [
        "-DUSE_CYBERRT"
    ],
    linkstatic = False,
)